package com.luke.dubbo.order.stub;

import com.luke.dubbo.api.bean.UserAddress;
import com.luke.dubbo.api.service.UserService;

import java.util.ArrayList;
import java.util.List;

/**
 * @Descrtption UserServiceStub
 * @Author luke
 * @Date 2020/3/26
 **/
public class UserServiceStub implements UserService {

    private final UserService userService;

    // 构造函数传入真正的远程代理对象
    public UserServiceStub(UserService userService){
        this.userService = userService;
    }

    @Override
    public List<UserAddress> getUserAddressList(String userId) {
        try {
            System.out.println("----UserServiceStub-----");
            //参数校验或者ThreadLocal本地缓存等
            return userService.getUserAddressList(userId);
        } catch (Exception e) {
            //容错处理
            return new ArrayList<>();
        }
    }

}
